<template>
  <div class="left-muen">
    <Scroll class="con">
      <div class="content">
        <van-sidebar v-model="active">
          <van-sidebar-item
            v-for="(item, index) in props.leftData"
            :key="index"
            :title="item.title"
            @click="getdata(item.maitKey, item.miniWallkey)"
          />
        </van-sidebar>
      </div>
    </Scroll>
  </div>
</template>

<script setup="props">
import { defineProps, onMounted, reactive, watch, nextTick } from "vue";
import Scroll from "@/components/common/Scroll.vue"; //滑动组件
import { subcategory, miniWallkey } from "@/utils/http.js";
import { Notify } from "vant";
import { ref, getCurrentInstance } from "vue";
// 获取this
const ctx = getCurrentInstance();
// 获取props
const props = defineProps({
  leftData: {
    type: Array,
    default: () => {},
  },
});

// 定义点击某一下
const active = ref(0);
// 定义点击事件
const getdata = async (id, id2, type) => {
  const { data: res } = await subcategory(id);
  if (!res.success) return Notify("请求失败");
  // 传递给父亲数据
  ctx.emit("rightdata", res.data.list);
};
getdata(3627);

</script>

<style lang="scss" scoped>
.con {
  width: 100px;
  position: absolute;
  left: 0;
  top: 44px;
  bottom: 35px;
  overflow: hidden;
}
</style>